//
//  QLUploadManager.m
//  WeiMiLan
//
//  Created by anan on 14/12/19.
//  Copyright (c) 2014年 Mac. All rights reserved.
//

#import "QLUploadManager.h"

@implementation QLUploadManager

-(id) init
{
    self = [super init];
    if (self) {
        self.uploads = [[NSMutableArray alloc] init];
    }
    return self;
}

static QLUploadManager *instance;

+ (QLUploadManager*)shareInstance
{
    if (instance == nil) {
        instance = [[QLUploadManager alloc] init];
    }
    return instance;
}

- (void)loadAllWithUserId:(int)userId callback:(QLHttpResultBlock)callback
{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic ql_setInterge:userId forKey:@"userId"];
    AFHTTPRequestOperationManager *requestManager = [AFHTTPRequestOperationManager manager];
    requestManager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [requestManager GET:@"http://ping.vsmu.cn/app/Interface/Package?ORDER_DIRECTION=0&type=1003" parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //[self setFavorites:responseObject[@"PACKAGE_RSP"][@"PACKAGE"] myUserId:userId];
        if (callback) {
            callback(NO,self.uploads);
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (callback) {
            callback(NO,nil);
        }
    }];
}

@end
